# 全局日志模块
import time


def __init():
    global _global_logs
    _global_logs = []


# 获取当前时间
def get_current_time():
    current_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
    return current_time


def logs_print(logs_value, save=False):
    current_time = get_current_time()
    logs_value = str(current_time) + " " + str(logs_value)
    print(logs_value)
    _global_logs.append(logs_value)
    if save:
        with open("logs", "w") as f:
            for i in _global_logs:
                f.write(i + "\n")
    return
